<template>
  <div class="error-container">
    <div class="error-card">
      <div class="error-illustration">
        <div class="error-number">
          <span class="digit">4</span>
          <div class="error-symbol">
            <div class="symbol-circle"></div>
            <el-icon class="symbol-icon"><CloseBold /></el-icon>
          </div>
          <span class="digit">4</span>
        </div>
        <div class="error-shadow"></div>
      </div>

      <div class="error-content">
        <h1 class="error-title">页面迷失在数字世界</h1>
        <p class="error-description">
          我们似乎找不到您要访问的页面，可能是链接失效或页面已被转移
        </p>

        <div class="countdown-box">
          <div class="countdown-circle">
            <el-icon><Clock /></el-icon>
          </div>
          <span>{{ countdown }}秒后自动返回安全区域</span>
        </div>

        <div class="action-buttons">
          <el-button 
            type="primary" 
            class="action-btn" 
            @click="goHome"
          >
            <el-icon class="btn-icon"><HomeFilled /></el-icon>
            <span>返回首页</span>
          </el-button>
          <el-button 
            class="action-btn secondary" 
            @click="goBack"
          >
            <el-icon class="btn-icon"><ArrowLeft /></el-icon>
            <span>返回上一页</span>
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { CloseBold, Clock, HomeFilled, ArrowLeft } from '@element-plus/icons-vue'

const router = useRouter()
const countdown = ref(5)

const goHome = () => router.push('/')
const goBack = () => router.go(-1)

onMounted(() => {
  const timer = setInterval(() => {
    countdown.value -= 1
    if (countdown.value <= 0) {
      clearInterval(timer)
      goHome()
    }
  }, 1000)
})
</script>

<style scoped>
.error-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
  padding: 2rem;
}

.error-card {
  max-width: 900px;
  width: 100%;
  background: white;
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  display: flex;
}

.error-illustration {
  flex: 1;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 4rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.error-number {
  display: flex;
  align-items: center;
  position: relative;
  z-index: 2;
}

.digit {
  font-size: 10rem;
  font-weight: 800;
  color: white;
  line-height: 1;
  text-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.error-symbol {
  width: 6rem;
  height: 6rem;
  margin: 0 1.5rem;
  position: relative;
}

.symbol-circle {
  width: 100%;
  height: 100%;
  background: #ff4757;
  border-radius: 50%;
  position: absolute;
  animation: pulse 2s infinite;
}

.symbol-icon {
  position: absolute;
  font-size: 3rem;
  color: white;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.error-shadow {
  position: absolute;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.error-content {
  flex: 1;
  padding: 4rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.error-title {
  font-size: 2.25rem;
  color: #2d3748;
  margin-bottom: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
}

.error-description {
  font-size: 1.1rem;
  color: #718096;
  margin-bottom: 2.5rem;
  line-height: 1.7;
}

.countdown-box {
  display: flex;
  align-items: center;
  background: #f8f9fa;
  padding: 1rem 1.5rem;
  border-radius: 50px;
  margin-bottom: 2.5rem;
  font-size: 1rem;
  color: #4a5568;
}

.countdown-circle {
  width: 36px;
  height: 36px;
  background: #667eea;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 1rem;
}

.countdown-circle .el-icon {
  color: white;
  font-size: 1.1rem;
}

.action-buttons {
  display: flex;
  gap: 1.5rem;
}

.action-btn {
  padding: 0.9rem 1.8rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 50px;
  transition: all 0.3s ease;
}

.action-btn.secondary {
  background: white;
  color: #4a5568;
  border: 1px solid #e2e8f0;
}

.action-btn.secondary:hover {
  background: #f8f9fa;
  border-color: #cbd5e0;
}

.btn-icon {
  margin-right: 0.5rem;
  font-size: 1.1rem;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.8;
  }
}

/* 响应式设计 */
@media (max-width: 992px) {
  .error-card {
    flex-direction: column;
  }
  
  .error-illustration {
    padding: 3rem 2rem;
  }
  
  .digit {
    font-size: 8rem;
  }
  
  .error-symbol {
    width: 5rem;
    height: 5rem;
    margin: 0 1rem;
  }
  
  .error-content {
    padding: 3rem;
  }
}

@media (max-width: 576px) {
  .error-container {
    padding: 1rem;
  }
  
  .digit {
    font-size: 5rem;
  }
  
  .error-symbol {
    width: 3.5rem;
    height: 3.5rem;
    margin: 0 0.8rem;
  }
  
  .symbol-icon {
    font-size: 2rem;
  }
  
  .error-title {
    font-size: 1.8rem;
  }
  
  .error-description {
    font-size: 1rem;
  }
  
  .action-buttons {
    flex-direction: column;
    gap: 1rem;
  }
  
  .action-btn {
    width: 100%;
  }
}
</style>
